package com.kintreda.ieco_server.core.service;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import com.kintreda.ieco_server.util.page.PageBean;

import org.hibernate.Criteria;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.jdbc.core.JdbcTemplate;

public interface IBaseService<M extends Serializable, PK extends Serializable> {
	
	public Serializable save(M m);

	public boolean delete(M m);

	public boolean deleteByPK(PK pk);

	public boolean deleteByPK(PK[] pk);

	public boolean deleteByPK(String hql, PK[] pk);

	public boolean deleteByPK(String hql, List<PK> pk);

	public boolean deleteAll(Collection<M> m);

	public boolean update(M m);

	public boolean saveOrUpdate(M m);

	public boolean saveOrUpdateAll(Collection<M> m);

	public boolean excute(String hql, Object[] params);

	public boolean excute(String hql, List<Object> params);
	
	public boolean excuteByListParam(String hql, List<?> params);
	
	public M load(PK pk);

	public M get(PK pk);

	public List<M> loadAll();

	public List<M> query(String hql, Object[] params);

	public List<Object[]> queryArray(String hql, Object[] params);

	public List<?> findByNamedParam(String hql, String paramName, Object value);

	public List<?> findByNamedParam(String hql, String[] paramNames,Object[] values);

	public Long count(String hql, Object[] values);
	
	public Long countByHql(String hql, Object[] values);
	
	public Long countByHql(String hql, Object[] values , Map<String, Object[]> map);

	public PageBean<M> queryPage(PageBean<M> bean, String hql, String orderBy,Object[] values);
	
	public DetachedCriteria getDetachedCriteria();
	public Criteria getCriteria();
	public JdbcTemplate getJdbcTemplate();
	public PageBean<Object[]> queryPage(PageBean<Object[]> bean,DetachedCriteria criteria);

	public PageBean<Object> queryPageArray(PageBean<Object> bean, String hql,String orderBy, Object[] values);
	public PageBean<Object> queryPageArray(PageBean<Object> bean, String hql,String countHql,String orderBy, Object[] values);
}
